<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- 
        产生: 在嵌套内部函数定义执行完时就产生了
        死亡: 咋嵌套的内部函数成为垃圾对象
     -->
    <script>
        function fn1() {
            let a = 2
            function fn2() {
                a++
                console.log(a)
            }
            return fn2
        }

        let f = fn1()
        f()
        f()

        f = null // 闭包死亡
    </script>
</body>

</html>